package com.inei.cie.utilitarios;

import java.util.List;

import com.inei.cie.R;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListadoLosasAdapter extends BaseAdapter {

	Context context;
	List<Integer> lista;

	public ListadoLosasAdapter(Context context, List<Integer> lista) {
		this.context = context;
		this.lista = lista;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lista.size();
	}

	@Override
	public Object getItem(int pos) {
		// TODO Auto-generated method stub
		return lista.get(pos);
	}

	@Override
	public long getItemId(int pos) {
		// TODO Auto-generated method stub
		return (long) lista.get(pos);
	}

	@Override
	public View getView(int pos, View v, ViewGroup vg) {
		// TODO Auto-generated method stub
		View item = v;
		ViewHolder holder;
		if (item == null) {
			LayoutInflater inflater = (LayoutInflater) context
					.getSystemService(context.LAYOUT_INFLATER_SERVICE);
			item = inflater.inflate(
					R.layout.capitulo_viii_otra_edificacion_estado, null);
			holder = new ViewHolder();
			holder.tv = (TextView) item.findViewById(R.id.tvEdificacion);
			holder.te = (TextView) item.findViewById(R.id.tvEstado);
			item.setTag(holder);
		} else {
			holder = (ViewHolder) item.getTag();
		}
		int num = lista.get(pos);
		String ld = (pos + 1) + "";
		holder.tv.setText("LD - " + (ld.length() == 1 ? "0" : "") + (pos + 1));
		// holder.tv.setText("LD - " + (pos + 1));
		holder.tv.setTextColor(Color.BLACK);
		if (num == 1) {
			holder.te.setText("COMPLETO");
			holder.te.setTextColor(Color.GREEN);
		} else {
			holder.te.setText("INCOMPLETO");
			holder.te.setTextColor(Color.RED);
		}
		return item;
	}

	static class ViewHolder {
		TextView tv;
		TextView te;
	}
}
